<template>
    <my-card style="width: 285px;height: 318px;" class="event-card">
        <div style="padding-left: 10px;padding-top: 10px;padding-right: 10px">
            <div style="border-radius: 5px;overflow: hidden;height: 140px;position: relative;">
                <img :src="data.imgPath?data.imgPath:'http://118.190.157.81:8080/G0/M00/00/00/rB-WVVyYbhWAZuYnAABmpEtO0i8144.png'"
                     style="width: 100%;height: 100%;object-fit: cover;"
                     alt="标题">
            </div>
            <div style="display: flex;flex-direction: row;margin: 15px 0">
                <div style="width: 64px;height: 68px;
                border-right: 1px solid #EAEDF3;display: flex;
                flex-direction: column;justify-content: center;
                align-items: center">
                    <div style="color: #9EA0A5;font-size: 12px;
                    font-weight: 600">
                        {{data.eventDeadTime | eventDateFormatWeek}}
                    </div>
                    <div style="color: #3E3F42;font-size: 26px">
                        {{data.eventDeadTime | eventDateFormatDate}}
                    </div>
                </div>
                <div style="flex: 1;display: flex;flex-direction: column;
                justify-content: space-between;margin-left: 20px">
                    <div>
                        <div class="text-overflow"
                             style="color: #3E3F42;font-weight: 600">
                            {{data.eventTitle}}
                        </div>
                        <div style="color: #6B6C6F;font-weight: 400">
                            {{data.eventDeadTime | eventDateFormat}} 截止
                        </div>
                    </div>
                    <div style="height: 24px;color: #9EA0A5;font-size: 12px">
                        35,890 人对此活动感兴趣
                    </div>
                </div>
            </div>
        </div>
        <div style="background-color: rgb(234, 237, 243);height: 1px"></div>
        <div style="padding:0 10px;border-top: 1px solid #EAEDF3;height: 69px">
            <div style="height:69px;flex: 1;display: flex;flex-direction: row;align-items:center;">
                <div style="flex: 1">
                    <div style="color: #9EA0A5;font-size: 12px;">审核进度</div>
                    <div style="display: flex;align-items: center">
                        <a-progress :percent="progress" :showInfo="false" />
                        <span style="font-size: 12px;color: #9EA0A5;margin-left: 10px">{{data.accessSize}}/{{data.auditSize}}</span>
                    </div>
                </div>
                <a-icon type="setting" style="font-size: 24px;color: #9EA0A5;margin-left: 56px" @click="clickHandler" class="setting"/>
            </div>
        </div>
    </my-card>
</template>

<script>
    const weekEum = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
    const monthEum = ['一月', '二月', '三月', '四月', '五月', '六月', '七月',
                      '八月', '九月', '十月', '十一月', '十二月'];
    export default {
        name: 'EventCard',
        props: {
            data: {
                type: Object,
            },
        },
        filters: {
            eventDateFormat (value) {
                if (!value) return '';
                const date = new Date(value);
                const month = monthEum[ date.getMonth() ];
                const day = date.getDate();
                const week = weekEum[ date.getDay() ];
                return month + ' ' + day + '日 ' + week;
            },
            eventDateFormatDate (value) {
                return new Date(value).getDate();
            },
            eventDateFormatWeek (value) {
                return weekEum[ new Date(value).getDay() ];
            },
        },
        computed: {
            progress () {
                if (this.data.auditSize!=0) {
                    return (this.data.accessSize/this.data.auditSize)*100;
                } else {
                    return 100;
                }
            },
        },
        methods: {
            clickHandler () {
                this.$router.push(`/event/admin/${this.data.eventId}`);
            },
        },
    };
</script>

<style scoped>
    .setting{
        transition: all 0.3s;
    }
    .setting:hover{
        transform: rotate(90deg);
        transition: all 0.3s;
    }
    .event-card{
        overflow: hidden;
        transition: all 0.3s;
    }
    img {
        height: 100%;
        width: auto;
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    .text-overflow {
        height: min-content;
        text-overflow: ellipsis;
        display: -webkit-box;
        word-break: break-all;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
    }
</style>
